package com.edu.controller.controller;

import com.edu.controller.dao.UserDao;
import com.edu.controller.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

@RestController
public class IndexController {

    @Autowired
    private UserDao userDao;
    @RequestMapping("/index")
    public User index(HttpServletRequest request){
        String id = request.getParameter("id");
        User user = new User();
        user.setAge("25");
        user.setId(1);
        user.setName("8888888");
        userDao.save(user);
        String pathInfo = request.getPathInfo();
        System.err.println("pathInfo===="+pathInfo);
        Enumeration<String> headerNames = request.getHeaderNames();
        System.err.println("headerNames===="+headerNames);
        String contextPath = request.getContextPath();
        System.err.println("contextPath===="+contextPath);
        String remoteUser = request.getRemoteUser();
        System.err.println("remoteUser===="+remoteUser);
       return userDao.findOne(Integer.valueOf(id));

    }
}
